package cn.fulong.smebj.mapper;

import cn.fulong.smebj.entity.Answer;
import cn.fulong.smebj.entity.SpecialTopic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface AnswerMapper extends BaseMapper<Answer> {

    @Select("select a.*,q.title,u.user_name,u.real_name\n" +
            "from Answer a\n" +
            "left join question q on a.question_id = q.id\n" +
            "left join user u on u.id=a.user_id")
    IPage<Map<String,Object>> queryList(IPage ipage);

    @Select("select * from Answer where question_id=#{qid} and user_id=#{userId}")
    List<Answer> query(@Param("qid") Long qid,@Param("userId") Long userId);
}